//
//  RTJAutoLendViewController.m
//  RuiTaiJinProject
//
//  Created by jayson on 2018/12/20.
//  Copyright © 2018年 leewei. All rights reserved.
//

#import "RTJAutoLendViewController.h"
#import "RTJBinDetailsCell.h"

@interface RTJAutoLendViewController ()

@property (weak, nonatomic) IBOutlet UITableView *tableView;


@end

@implementation RTJAutoLendViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.tableFooterView=[UIView new];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
    self.tableView.estimatedRowHeight=300;
    
    if ([_data[@"load_list"] count] == 0) {
        
        [self.view showEmptyViewWithStr:@"暂无数据" image:[UIImage imageNamed:@"kbylogo"] callback:^{
            
            [self.tableView reloadData];

        }];
        
    }else{
        
        [self.view removeEmptyView];
        [self.tableView reloadData];

    }
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return [_data[@"load_list"] count];
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return UITableViewAutomaticDimension;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * ID = @"RTJBinDetailsCell";
    
    NSArray *arr = @[@"icon_pc",@"icon_web",@"icon_weixin",@"icon_ios",@"icon_android"];

    RTJBinDetailsCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (!cell) {
        
        cell = [[NSBundle mainBundle] loadNibNamed:@"RTJBinDetailsCell" owner:self options:nil][1];
    }
    cell.phone.text = [NSString stringWithFormat:@"%@",_data[@"load_list"][indexPath.row][@"mobile"]];
    cell.shijian.text = [NSString stringWithFormat:@"%@",_data[@"load_list"][indexPath.row][@"create_time"]];
    cell.money.text = [NSString stringWithFormat:@"¥ %@ 元",_data[@"load_list"][indexPath.row][@"money"]];
    
    NSInteger source = [_data[@"load_list"][indexPath.row][@"source"] integerValue];
    cell.img.image = [UIImage imageNamed:arr[source]];
    
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return  cell;
    
}

@end
